<template>
  <div class="mv_mian">
    <div class="mv_list">
      <div class="mvItem" v-for="item in mvList" :key="item.id">
        <div class="mvUrl">
          <img :src="item.cover" alt="" />
          <div class="mvBox"></div>
          <span class="mvUrlIcon" style="color: #fff">
            <el-icon size="45"> <VideoPlay /> </el-icon>
          </span>
        </div>
        <div class="mvInfo">
          <div class="mvTitle">
            {{ item.name }}
          </div>
          <div class="mvAuth">
            {{ item.artistName }}
          </div>
          <div class="mvLook">
            <el-icon size="20" style="padding-right: 5px">
              <VideoCameraFilled /> </el-icon
            >{{ playCountFilter(item.playCount) }}人观看
          </div>
        </div>
      </div>
    </div>
    <div class="mv_search">
      <div class="mv_search_item" v-for="(item,index) in mvSearchOption" :key="index">
        <div class="mv_search_title">{{item.title}}</div>
        <div class="mv_search_tag">
          <span v-for="(jitem,index) in item.list" :key="index">{{jitem}}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive, toRefs, onMounted, inject } from "vue";
const axios = inject("$axios");
const mvList = ref([]);
// 处理播放数过万
const playCountFilter = (num: number) => {
  if (num > 9999) {
    return Math.round(num / 1000) / 10 + "万";
  } else {
    return num;
  }
};

const mvSearchOption = ref([
  {
    title: "全部",
    list: ["上升最快","最新"],
  },
  {
    title: "区域",
    list: ["内地","港台","欧美","日本","韩国"],
  },
  {
    title: "类型",
    list: ["原生","现场版","网易出品","官方版"],
  }
]);

// MV
const getMvList = async () => {
  const { data: resData } = await axios.get(
    `http://127.0.0.1:3000/mv/all?area=&type=&order=&limit=30&offset=0`
  );
  mvList.value = resData.data;
};

onMounted(() => {
  getMvList();
});
</script>
<style scoped lang="scss">
.mv_mian {
  display: flex;
  justify-content: space-around;

  .mv_list {
    flex: 1;
    background-color: #fff;
    padding: 15px;
    border-radius: 10px;
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-right: 15px;
    .mvItem {
      width: 220px;
      height: 240px;
      margin-bottom: 14px;
      margin-right: 19px;
      font-size: 14px;
      .mvUrl {
        width: 100%;
        height: 120px;
        background-color: aliceblue;
        border-radius: 8px;
        overflow: hidden;
        position: relative;

        .mvBox {
          width: 100%;
          height: 120px;
          background: rgba(0, 0, 0, 0.2);
          position: absolute;
          top: 0px;
          left: 0px;
          z-index: 1;
        }

        .mvUrlIcon {
          position: absolute;
          top: 50%;
          left: 50%;
          transform: translate(-50%, -50%);
          z-index: 2;
        }

        img {
          width: 100%;
        }
      }

      .mvTitle {
        margin-top: 8px;
      }

      .mvAuth {
        margin: 5px 0px;
        color: #999;
        font-size: 12px;
      }

      .mvLook {
        font-size: 12px;
        display: flex;
        align-items: end;
      }
    }
  }

  .mv_search {
    width: 360px;
    height: 100%;
    border-radius: 10px;
    background-color: #fff;
    padding: 15px;
    box-sizing: border-box;

    .mv_search_item {
      margin-bottom: 20px;
      font-size: 16px;
      .mv_search_title {
        font-weight: bold;
        padding-bottom: 8px;
      }
      .mv_search_tag {
        display: flex;
        justify-content: flex-start;
        font-size: 14px;
        color: #333;
        span {
          position: relative;
          display: inline-block;
          z-index: 1;
          margin-right: 10px;
          // &::after {
          //   position: absolute;
          //   content: "";
          //   left: 0;
          //   bottom: 0px;
          //   width: 100%;
          //   height: 6px;
          //   background: #ff641e;
          //   z-index: -1;
          // }
        }
      }
    }
  }
}
</style>